package com.hs.auth.action;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.hs.auth.service.IPowerService;
import com.hs.core.action.BaseAction;
import com.hs.core.utils.PageParam;
import com.hs.core.utils.PageUtil;
@Controller  
public class PowerController  extends BaseAction {
    /**
	 * 
	 */
	private static final long serialVersionUID = -354434172898440670L;
	private static final Logger logger = Logger.getLogger(PowerController.class);
	private IPowerService powerService;
	 @Autowired  
	public void setPowerService(IPowerService powerService) {
		this.powerService = powerService;
	}
	 /**
	  * 权限信息
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/auth/powerInfo.do", method = RequestMethod.GET)   
     public ModelAndView powerInfo(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
         String roleid = request.getParameter("roleid");//是否存在此参数表明是新增还是修改
		 return null;
		 
	 }
	 /**
	  * 权限信息保存
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/auth/savePower.do", method = RequestMethod.POST)   
     public ModelAndView savePower(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
         String orgid = request.getParameter("roleId");//是否存在此参数表明是新增还是修改
		 return null;
		 
	 }
	 /**
	  * 权限列表
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/auth/listPower.do", method = RequestMethod.GET)   
     public ModelAndView listPower(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		    PageParam pageParam = new  PageParam(request,"data/listData.do");
			StringBuffer buffer = new StringBuffer();
			 
//		    pageParam.getConditionMap().put("orderName", orderName);
//		    pageParam.getConditionMap().put("orderNum", orderNum);
		    
		    //排序结束
			PageUtil pageUtil = null;
			StringBuffer searchBuffer = new StringBuffer(" select a from PdmsPreinfo a where a.isdelete='0'  ");
			String prename = request.getParameter("prename"); 
			String precomfrom = request.getParameter("precomfrom"); 
			String pstatus = request.getParameter("pstatus"); 
			String dbsourse = request.getParameter("dbsourse"); 

			 
			if(StringUtils.isNotBlank(prename)){
				searchBuffer.append(" and a.prename like ?");
				pageParam.getConditionMap().put("prename", prename);
				request.setAttribute("prename", prename);
			}  
			 
			 searchBuffer.append(" order by a.prename,a.precomfrom");
			 
			pageParam.setSearchSql(searchBuffer.toString());
			pageUtil = powerService.getPowerList(pageParam);
			modelMap.put("dataList", pageUtil);   
			//List dbsList = dataService.findList("select a  from PdmsDsConfig a ");
	 		//data.put("dbslist", dbsList);
			return new ModelAndView("../../app/data/dataList",modelMap);   
		 
	 }
	  
	 
}
